import request from 'UTIL/request'

/**
 * 商机列表
 * @param params
 */
export function GetList(params) {
  return request({
    url: 'crmBusiness/queryPageList',
    method: 'POST',
    data: params
  })
}

/**
 * 商机详情
 * @param params
 */
export function QueryById(params) {
  return request({
    url: `crmBusiness/queryById/${params.businessId}`,
    method: 'POST',
    data: params
  })
}

/**
 * 基本信息
 */
export function InformationById(params) {
  return request({
    url: `crmBusiness/information/${params.id}`,
    method: 'POST',
    data: params
  })
}

/**
 * 新增/编辑时查询字段
 */
export function QueryFieldList(params) {
  const query = params && params.id ? `/${params.id}` : ''
  return request({
    url: `crmBusiness/field${query}`,
    method: 'POST',
    data: params,
		requestType: 'form'
  })
}

/**
 * 商机创建
 */
export function AddBusiness(params) {
  return request({
    url: 'crmBusiness/add',
    method: 'POST',
    data: params
  })
}

/**
 * 商机修改
 */
export function UpdateBusiness(params) {
  return request({
    url: 'crmBusiness/update',
    method: 'POST',
    data: params
  })
}

/**
 * 商机删除
 * @param params
 */
export function DeleteByIds(params) {
  return request({
    url: 'crmBusiness/deleteByIds',
    method: 'POST',
    data: params
  })
}

/**
 * 商机转移
 * @param params
 */
export function Transfer(params) {
  return request({
    url: 'crmBusiness/changeOwnerUser',
    method: 'POST',
    data: params
  })
}

/**
 * 商机相关产品
 * @param params
 */
export function QueryProduct(params) {
  return request({
    url: 'crmBusiness/queryProduct',
    method: 'POST',
    data: params
  })
}

/**
 * 商机相关合同
 * @param params
 */
export function QueryContract(params) {
  return request({
    url: 'crmBusiness/queryContract',
    method: 'POST',
    data: params
  })
}

/**
 * 商机相关团队
 * @param params
 */
export function GetMembers(params) {
  return request({
    url: `crmBusiness/getMembers/${params.id}`,
    method: 'POST'
  })
}

/**
 * 商机添加团队成员
 * @param params
 */
export function AddMembers(params) {
  return request({
    url: 'crmBusiness/addMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 商机修改团队成员
 * @param params
 */
export function UpdateMembers(params) {
  return request({
    url: 'crmBusiness/updateMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 商机删除团队成员
 * @param params
 */
export function DeleteMembers(params) {
  return request({
    url: 'crmBusiness/deleteMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 商机状态组
 * @param params
 */
export function QueryBusinessStatus(params) {
  return request({
    url: `crmBusiness/queryBusinessStatus/${params.id}`,
    method: 'POST'
  })
}

/**
 * 商机状态组选项
 * @param params
 */
export function BusinessStatusOptions(params) {
  return request({
    url: 'crmFlow/queryBusinessSetting',
    method: 'POST',
    data: params
  })
}

/**
 * 商机状态推进
 * @param params
 */
export function BoostBusinessStatus(params) {
  return request({
    url: 'crmBusiness/boostBusinessStatus',
    method: 'POST',
    data: params
  })
}

/**
 * 商机跟进记录
 * @param params
 */
export function GetRecord(params) {
  return request({
    url: 'crmBusiness/getRecord',
    method: 'POST',
    data: params
  })
}

/**
 * 商机跟进记录
 * @param params
 */
export function AddRecord(params) {
  return request({
    url: 'crmBusiness/addRecord',
    method: 'POST',
    data: params
  })
}

/**
 * 查询商机下附件列表
 * @param params
 */
export function QueryFileList(params) {
  return request({
    url: 'crmBusiness/queryFileList',
    method: 'POST',
    data: params,
		header: {
			'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
  })
}
